# Aerospike database developer configuration file.

service {
  run-as-daemon false # To work with gdb, and make console logging visible.

  service-threads {{ service_threads }}

  # The number of concurrent connections to the database is limited by
  # proto-fd-max, and by the system's maximum number of open file descriptors.
  # See "man limits.conf" for how to set the system's "nofile" limit.
  proto-fd-max {{ proto_fd_max }}

  work-directory run/work
  pidfile run/asd.pid
}

mod-lua {
  user-path run/work/usr/udf/lua
}

logging {
  # Log file must be an absolute path.
  file run/log/aerospike.log {
    context any info
  }

  console {
    context any info
  }
}

network {
  service {
    address any
    port {{ port_prefix }}000
  }

  heartbeat {
    mode mesh
    port {{ port_prefix }}002

    # To use unicast-mesh heartbeats, remove the 3 lines above, and see
    # aerospike_mesh.conf for alternative.

    {%- for address in seed_addresses|default([], true) %}
        mesh-seed-address-port {{ address }}  {{ port_prefix }}002 # IP address for seed node in the cluster
    {% endfor %}

    interval 150
    timeout 10
  }

  fabric {
    port {{ port_prefix }}001
  }

  info {
    port {{ port_prefix }}003
  }
}

namespace test {
  replication-factor {{ replication_factor }}
  memory-size {{ memory_size }}K
  default-ttl 0 # never expire/evict.
  {# if storage devices are passed to the template, use them for storage; otherwise use memory. -#}
  {% if devices %}
  storage-engine device { # Configure the storage-engine to use persistence
  {% for device_path in devices %}
  device {{ device_path }}
  {% endfor %}
  write-block-size 128K   # adjust block size to make it efficient for SSDs
  }
  # As noted in https://discuss.aerospike.com/t/buffering-and-caching-in-aerospike/5623,
  # running with disable-odirect true could lead to more extensive data loss
  # since it disabled odirect for all IO.
  {% else %}
  storage-engine memory
  {% endif %}
}

namespace bar {
  replication-factor 2
  memory-size 4G

  storage-engine memory

  # To use file storage backing, comment out the line above and use the
  # following lines instead.
#  storage-engine device {
#    file /opt/aerospike/data/bar.dat
#    filesize 16G
#    data-in-memory true # Store data in memory in addition to file.
#  }
}
